<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>登录</title>
		<link rel="stylesheet" type="text/css" href="/node_modules/bootstrap/dist/css/bootstrap.css"/>
		<script type="text/javascript" src="/node_modules/jquery/dist/jquery.js"></script>
	</head>
	<body>
		<div class="panel panel-primary">
		  <div class="panel-heading">用户登录</div>
		  <div class="panel-body">
			<form id="loginform">
			  <div class="form-group form-inline">
			    <label for="userName">用户名</label>
			    <input type="text" class="form-control" id="userName" name="userName" placeholder="请输入用户名" required="true">
			  </div>
			  <div class="form-group form-inline">
			    <label for="password">密码</label>
			    <input type="password" class="form-control" id="password" name="password" placeholder="请选择密码" required="true">
			  </div>
			  <input type="button" id="loginBut" class="btn btn-primary" value="登录">
			</form>
		  </div>
		</div>
	</body>
	<script type="text/javascript">
		function login(){
			$.ajax({
				url: "/login",
				data: $('#loginform').serialize(),
				method: "post",
				dataType: "json",
				success: function(data) {
					if(data.code == 0){
						window.location.href = "/"
					}else{
						alert(data.msg);
						return;
					}
				}
			});
		}
		$("#loginBut").on("click",function(){
			$.ajax({
				url: "/login",
				data: $('#loginform').serialize(),
				method: "post",
				dataType: "json",
				success: function(data) {
					if(data.code == 0){
						window.location.href = "/"
					}else{
						alert(data.msg);
						return;
					}
				}
			});
		});
	</script>
</html>
